#ifndef __WINGFX_H
#define __WINGFX_H

#include <allegro.h>

#define GUI_TILE_W 8
#define GUI_TILE_H 8
#define GUI_OFFSET 24
#define GUI_CAPTION_MAXLEN 100

typedef struct {
	BITMAP* setbmp; // tileset for win gfx containing this Window
	int set; // Index of the set in setbmp to use
	int x, y; // in pixels
	int w, h; // in GUI_TILE_W*GUI_TILE_H tiles
} Window;

typedef struct {
	BITMAP* setbmp;
	int set;
	int x, y; // in pixels
	int w; // in GUI_TILE_W pixels wide tiles
	int pressed; // true if mouse is being held down over button
	int clicked; // true if click event has happened
	FONT* font;
	char caption [GUI_CAPTION_MAXLEN];
} Button;

typedef struct {
	BITMAP* setbmp;
	int set;
	int x, y; // in pixels
	int w; // in GUI_TILE_W pixels wide tiles
	FONT* font;
	char caption [GUI_CAPTION_MAXLEN];
} Textfield;

void window_draw (BITMAP* target, Window* window);
void button_draw (BITMAP* target, Button* button, int pressed);
void textfield_draw (BITMAP* target, Textfield* textfield);

void button_mouseevent (Button* button, int mouse_x, int mouse_y, int mouse_button);
int button_was_clicked (Button* button);
void textfield_type (Textfield* textfield, char c);
int textfield_is_clicked (Textfield* textfield, int mouse_x, int mouse_y, int mouse_button);

#endif /* __WINGFX_H */
